home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr48 / pasclern.zip / CONVERT.PAS < prev    next >
Pascal/Delphi Source File  |  1993-04-01  |  881b  |  29 lines

  1. PROGRAM convert_from_type_to_type;
  2.  
  3. VAR index,count : INTEGER;
  4.     error_ind   : INTEGER;
  5.     size,cost   : REAL;
  6.     letter      : CHAR;
  7.     name,amount : STRING[12];
  8.  
  9. BEGIN
  10.   index := 65;
  11.   count := 66;
  12.   cost := 124.678;
  13.   amount := '12.4612';
  14.  
  15.   letter := chr(index);       (* convert integer to char *)
  16.   size := count;              (* convert integer to real *)
  17.  
  18.   index := round(cost);       (* real to integer, rounded *)
  19.   count := trunc(cost);       (* real to integer, truncated *)
  20.  
  21.   index := ord(letter);       (* convert char to integer *)
  22.   str(count,name);            (* integer to string of char *)
  23.   val(amount,size,error_ind); (* string to real  note that
  24.                                  "err_ind" is used for return-
  25.                                  ing an error code *)
  26.  
  27.   WRITELN('Name is ',name,' and size is ',size:10:4);
  28.  
  29. END.